<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function create_pdf($data, $title,$reportSetting) 
{
	    require_once(dirname(__FILE__).'/tcpdf/config/lang/eng.php');
	    require_once(dirname(__FILE__).'/tcpdf/tcpdf.php');
		  
	 //   echo $html;
	$pdf = new TCPDF();
	    
	// set document information
	$pdf->SetCreator('med-dots');
	$pdf->SetAuthor('med-dots');
	$pdf->SetTitle('med-dots Report');
	$pdf->SetSubject($title);
		
	// set default header data
	$pdf->SetHeaderData($reportSetting['logo'], PDF_HEADER_LOGO_WIDTH, $reportSetting['header1'],$reportSetting['header2']);
	// set default footer data
	$pdf->SetFooterData($reportSetting['logo'], PDF_FOOTER_LOGO_WIDTH, $reportSetting['footer1'],$reportSetting['footer2']);
	
	// set header and footer fonts
	$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
	$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
	
	// set default monospaced font
	$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
	
	//set margins
	$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
	$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
	$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
	
	//set auto page breaks
	$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
	
	//set image scale factor
	$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
	
	//set some language-dependent strings
	$pdf->setLanguageArray($l);
	
	// ---------------------------------------------------------
	
	// set default font subsetting mode
	$pdf->setFontSubsetting(true);
	
	// Set font
	// dejavusans is a UTF-8 Unicode font, if you only need to
	// print standard ASCII chars, you can use core fonts like
	// helvetica or times to reduce file size.
	$pdf->SetFont('dejavusans', '', 14, '', true);
	
	// Add a page
	// This method has several options, check the source code documentation for more information.
	$pdf->AddPage();
	    $pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $data, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
	    $pdf->Output("$title -".time().".pdf");
	    
	   
}
  